﻿
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



CREATE PROCEDURE [dbo].[bhp_NemoRecordDelete]
	@GroupId	INT,
	@RecordId	INT
AS
BEGIN

	
	DECLARE @Q NVARCHAR(1000)
	
	SET @Q = 'UPDATE T' + CAST(@GroupId as NVARCHAR(10)) + ' SET del=1, mtime=GETDATE(), muser=7000002 WHERE idx=' + CAST(@RecordId as NVARCHAR(10))
	EXEC sp_executesql @Q
	SET @Q = 'UPDATE R' + CAST(@GroupId as NVARCHAR(10)) + ' SET del=1, mtime=GETDATE(), muser=7000002 WHERE idx=' + CAST(@RecordId as NVARCHAR(10))
	EXEC sp_executesql @Q
	
	
END

GO

CREATE PROCEDURE [dbo].[bhp_NemoUsers]
AS
BEGIN

	SELECT 
		3000000 + idx as UserId,
		imie + ' ' + nazwisko as Name
	FROM 
		T1
	WHERE
		del = 0
		AND (imie IS NOT NULL OR nazwisko IS NOT NULL)

END
GO

